#!/bin/bash

# 检查是否为root用户
if [ "$(id -u)" != "0" ]; then
   echo "该脚本必须以root权限运行" 1>&2
   exit 1
fi

# 读取用户输入的监听端口
read -p "请输入Squid监听的端口号: " port

# 安装Squid
apt-get update
apt-get install -y squid

# 备份原始配置文件
cp /etc/squid/squid.conf /etc/squid/squid.conf.bak

# 配置Squid
cat > /etc/squid/squid.conf <<EOF
http_port $port accel allow-direct
acl all src all
http_access allow all

# 其他配置...
EOF

# 重启Squid服务以应用更改
systemctl restart squid

# 检查Squid服务状态
systemctl status squid

echo "Squid已部署在端口$port，允许所有IP连接。"
